<template>
  <div class="store-repair-index">
    <div class="app-main">

      <div class="app-header"><img src="static/img/cs.jpg"></div>
      <!--<mt-cell v-for="(item,index) in slideList" class="staff-details" :title="item.remark" is-link :to="{path:item.name}">-->
        <!--<span  v-if="item.name=='report-order-list'" slot="icon" class="iconfont icon-quanbudingdan"></span>-->
        <!--<span  v-if="item.name=='store-role-list'" slot="icon" class="iconfont icon-tuandui"></span>-->
        <!--<span  v-if="item.name=='store-add-user'" slot="icon" class="iconfont icon-tuandui"></span>-->
        <!--<span  v-if="item.name=='member-center'" slot="icon" class="iconfont icon-user"></span>-->
      <!--</mt-cell>-->
      <ul class="module-list">
        <li class="item" v-for="(item,index) in slideList">
          <router-link class="item-content" :to="{path:item.name}" v-if="item.name=='report-order-list'">
              <div class="item-iconfont"><span class="iconfont icon-quanbudingdan" style="background: #c34853;"></span></div>
              <div class="item-title">{{item.remark}}</div>
          </router-link>
          <router-link class="item-content" :to="{path:item.name}" v-if="item.name=='member-center'">
            <div class="item-iconfont"><span class="iconfont icon-user" style="background: #63bd65;"></span></div>
            <div class="item-title">{{item.remark}}</div>
          </router-link>
          <router-link class="item-content" :to="{path:item.name}" v-if="item.name=='store-role-list'">
            <div class="item-iconfont"><span class="iconfont icon-tuandui" style="background: #3175fb;"></span></div>
            <div class="item-title">{{item.remark}}</div>
          </router-link>
          <router-link class="item-content" :to="{path:item.name}" v-if="item.name=='store-add-user'">
            <div class="item-iconfont"><span class="iconfont icon-tuandui" style="background: #c6872d;"></span></div>
            <div class="item-title">{{item.remark}}</div>
          </router-link>
        </li>
      </ul>
  </div>
  </div>
</template>
<script>
  import { Header,Swipe, SwipeItem,MessageBox } from 'mint-ui';
  export default {
    data () {
      return {
        storeType:'',
        slideList:[],
      }
    },
    created(){

      var turl=(location.href).split('/')[2];
      var getCode=(location.href).split('code=')[1];
      var wxcode='';
      if(typeof getCode!=='undefined'){
        wxcode=getCode.split('&')[0];
      }else{
        wxcode=''
      }
      var params = new URLSearchParams();
      params.append('thisUrl',location.href);
      params.append('wxCode',wxcode);
      this.$axios({
        method: 'post',
        url:'gp/Oauth/authorizeOfficial',
        data:params,
      }).then((res)=>{
        console.log(res)
      if(res.data.statusCode==300){
        window.location.href=res.data.object;
      }else{
        console.log(res)
      }
    });


      this.getStoreData();

    },
    methods:{
      getStoreData() {
        /**获取门店数据**/
        var params = new URLSearchParams();
        params.append('page',1);
        this.$axios({
          method: 'post',
          url:'gp/dataStatics/getStoreData',
          data:params
        }).then((res)=>{
          console.log(res)
          this.storeType=res.data.object.storeType;

        if(this.storeType==1){
          MessageBox.alert('您的账号身份为汽车玻璃服务门店，请返回登录汽修厂账号或申请新的汽修厂账号',).then(action => {
            if(action=='confirm'){
            this.$router.push({path:'/login'})
          }
        });
        }else{
          var params = new URLSearchParams();
          this.$axios({
            method: 'post',
            url:'gp/users/getUserInfo',
            data:params
          }).then((res)=>{
            if(res.data.statusCode==200){

            console.log(res,1111)
            this.slideList=[];
            for(var i=0;i<res.data.object.permList.length;i++){
              if(res.data.object.permList[i].type==1){
                const item={
                  name: res.data.object.permList[i].name,
                  remark: res.data.object.permList[i].remark,
                }
                this.slideList.push(item);
              }
            }
          }
        })
        }
      })
      },
      handleGoLogin(){

      },
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->

<style>
  body{
    font-size: 28px;
  }
  .store-repair-index .app-header{
    padding:0 0 12px;
    text-align: center;
  }
  .store-repair-index .module-list{
    display: flex;
    flex-wrap:wrap;
    padding:0 6px;
  }
  .store-repair-index .module-list .item{
    display: flex;
    width: 50%;
    padding:6px;
  }
  .store-repair-index .module-list .item-content{
    background: #fff;
    box-shadow: 0px 3px 10px 0px rgba(0, 0, 0, 0.02);
    flex-wrap:wrap;
    width: 100%;
    padding:32px 0;
    border-radius:3px;
    justify-content:center;
    font-size: 16px;
    color: #333;
    text-align: center;
  }
  .store-repair-index .module-list .iconfont{
    display:flex;
    justify-content:center;
    width:46px;
    height:46px;
    border-radius:50%;
    font-size:28px;
    color: #fff;
    align-items:center;
  }
  .store-repair-index .module-list .item-iconfont{
    display:flex;
    width: 100%;
    padding:0 0 4px;
    justify-content:center;
    text-align: center;

  }
</style>
